# 0. 编译并打包项目
mvn clean package

# 1. 登录为管理员
echo "[测试1] 登录为管理员，期望：登录成功，当前用户：admin"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --login --user admin

# 2. 添加店长和售票员
echo "[测试2] 添加店长，期望：添加用户成功"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --add-user --id u2 --username manager --role MANAGER --superior admin
echo "[测试3] 添加售票员，期望：添加用户成功"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --add-user --id u3 --username cashier --role CASHIER --superior u2

# 3. 测试用户管理功能
echo "[测试4] 修改用户信息，期望：修改成功"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --update-user --id u2 --username newmanager --role MANAGER --superior admin

# 4. 添加电影、放映厅
echo "[测试5] 添加电影，期望：添加电影成功"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --add-movie --id m1 --name "流浪地球" --duration 120
echo "[测试6] 添加放映厅，期望：添加放映厅成功"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --add-room --id r1 --name "IMAX厅" --rows 10 --cols 15

# 5. 切换为店长，添加排片
echo "[测试7] 切换为店长，期望：登录成功，当前用户：u2"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --login --user u2
echo "[测试8] 店长添加排片，期望：添加排片成功"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --add-schedule --id s1 --movie m1 --room r1 --start "2025-07-18 14:00" --end "2025-07-18 16:00"

# 6. 切换为售票员，售票
echo "[测试9] 切换为售票员，期望：登录成功，当前用户：u3"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --login --user u3
echo "[测试10] 售票员售票，期望：售票成功"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --sell-ticket --schedule s1 --row 3 --col 5 --phone 13800138000

# 7. 查询排片座位状态和统计
echo "[测试11] 查询排片座位状态，期望：部分座位为X（已售），其余为O（可售）"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --seat-status --schedule s1
echo "[测试12] 查询座位统计，期望：显示已售和可售座位数量"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --seat-statistics --schedule s1

# 8. 查询所有电影、放映厅、排片
echo "[测试13] 查询所有电影，期望：包含流浪地球"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --list-movies
echo "[测试14] 查询所有放映厅，期望：包含IMAX厅"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --list-rooms
echo "[测试15] 查询所有排片，期望：包含s1排片"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --list-schedules

# 9. 测试查询功能
echo "[测试16] 查询当前上映电影，期望：显示正在上映的电影"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --current-movies
echo "[测试17] 按电影名称查询排片，期望：显示流浪地球的排片"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --query-schedule-by-movie --name "流浪地球"
echo "[测试18] 按放映厅查询排片，期望：显示r1放映厅的排片"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --query-schedule-by-room --room r1
echo "[测试19] 按时间范围查询排片，期望：显示指定时间范围内的排片"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --query-schedule-by-time --start "2025-07-18 12:00" --end "2025-07-18 18:00"

# 10. 测试删除功能（需要管理员权限）
echo "[测试20] 切换为管理员，期望：登录成功，当前用户：admin"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --login --user admin
echo "[测试21] 删除排片，期望：删除成功"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --delete-schedule --id s1
echo "[测试22] 删除放映厅，期望：删除成功"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --delete-room --id r1
echo "[测试23] 删除用户，期望：删除成功"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --delete-user --id u3

# 11. 验证删除结果
echo "[测试24] 查询所有排片，期望：排片已被删除"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --list-schedules
echo "[测试25] 查询所有放映厅，期望：放映厅已被删除"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --list-rooms

# 12. 登出
echo "[测试26] 登出，期望：已登出"
java -jar target/cinema-management-1.0-SNAPSHOT-jar-with-dependencies.jar --logout

echo "=== 测试完成 ==="
echo "所有测试已执行完毕，请检查上述输出结果是否符合预期。" 